package cn.itsub.proxy.server;

import cn.itsub.proxy.common.Config;
import cn.itsub.proxy.server.work.config.ServerProperties;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.util.FileCopyUtils;
import org.springframework.util.StreamUtils;

import java.io.*;
import java.util.TimeZone;

@EnableAsync
@ServletComponentScan
@SpringBootApplication
public class ProxyServerApplication {

    public static void main(String[] args) {

        //创建数据库文件
        File dbfile = new File("data.db");
        if (!dbfile.exists()) {
            try {
                InputStream in = ProxyServerApplication.class.getClassLoader().getResourceAsStream("data.db");
                FileCopyUtils.copy(in, new FileOutputStream(dbfile));
            } catch (Exception e) {
                e.printStackTrace();
                return;
            }

        }


        TimeZone.setDefault(TimeZone.getTimeZone("GMT+8"));
        SpringApplication.run(ProxyServerApplication.class, args);
        System.out.println("启动成功");
    }

}
